home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disk User Volume 2 #4
/
Commodore_Disk_User_Vol.2_4_1989_-.d64
/
filter demo
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
7KB
|
238 lines
100 rem * filter demo program *
110 rem * for use with sid sequencer *
120 rem * by v.h.berry 1989 *
200 gosub 50010:rem initialisation
210 gosub 30010:rem enter filename
220 gosub 40010:rem load music
230 gosub 42010:rem load sound
240 gosub 5010:rem print screen
250 gosub 2010:rem start music
1000 rem sweep filter routine
1010 a=d1:d1=d2:d2=a:sw=-sw:i=d1
1020 get k$:if k$=chr$(136) then 1510:rem f7 exit program
1022 if k$=chr$(135) then gosub 2010:rem f5 music on/off
1024 if k$=chr$(134) then gosub 6010:rem f3 help
1026 if k$=chr$(133) then gosub 1810:rem f1 change sweep parameters
1028 if k$="1" then fg=f1:gosub 1610:f1=fg:gosub 1710:rem chan 1 filter on/off
1030 if k$="2" then fg=f2:gosub 1610:f2=fg:gosub 1710:rem chan 2 filter on/off
1032 if k$="3" then fg=f3:gosub 1610:f3=fg:gosub 1710:rem chan 3 filter on/off
1034 if k$="h" then fg=hp:gosub 1610:hp=fg:gosub 1710:rem high pass on/off
1036 if k$="l" then fg=lp:gosub 1610:lp=fg:gosub 1710:rem low pass on/off
1038 if k$="b" then fg=bp:gosub 1610:bp=fg:gosub 1710:rem band pass on/off
1040 if k$="v" then fg=volume:gosub 1660:volume=fg:gosub 1710:rem increase volume
1042 if k$="[214]" then fg=volume:gosub 1680:volume=fg:gosub 1710:rem decrease volume
1044 if k$="r" then fg=res:gosub 1660:res=fg:gosub 1710:rem increase resonance
1046 if k$="[210]" then fg=res:gosub 1680:res=fg:gosub 1710:rem decrease resonance
1050 i=i+sw:if (sgn(sw)=1)and(i>=d2) then 1010
1060 if (sgn(sw)=-1)and(i<=d2) then 1010
1080 poke sid+22,i:print"";tab(29);" [157][157][157][157]";i
1090 goto 1020
1500 rem exit program
1510 print"[147]filter demo"
1520 print"v.h.berry"
1530 print"1989."
1540 end
1600 rem on/off routine
1610 if fg=0 then fg=1:return
1620 fg=0:return
1650 rem increment/decrement parameter
1660 fg=fg+1:if fg>15 then fg=15
1670 return
1680 fg=fg-1:if fg<0 then fg=0
1690 return
1700 rem new filter setting
1710 gosub 50280:rem calculate new values
1720 gosub 2030:rem alter sid registers
1730 gosub 5220:rem print values
1740 return
1800 rem alter sweep filter parameters
1810 print"[147] change sweep filter parameters [146]"
1811 print"[176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][174]"
1812 print" sweep rate"
1814 print" limit 'x'"
1816 print" limit 'y'"
1818 print" continue"
1819 print"[173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][189]"
1820 gosub 5110:rem screen parameters
1830 print"";:ll=3:t1=4:gosub 39010:rem menu routine
1840 if a=3 then i=d1:gosub 5020:return
1845 fg=a:print"";tab(20);"enter value (0-255)[146]"
1850 l=3:tb=25:rs=0:gosub 32040:rem input subroutine
1855 if y$="" then 1810
1856 if val(y$)<0 or val(y$)>255 then print tab(25);"":goto 1850
1860 if fg=0 then sw=val(y$):rem change rate
1862 if fg=1 then d1=val(y$):rem change lower limit
1864 if fg=2 then d2=val(y$):rem change upper limit
1866 if d1>d2 and sgn(sw)=1 then sw=-sw
1868 if d1<d2 and sgn(sw)=-1 then sw=-sw
1870 goto 1810
2000 rem music on/off
2010 if mf=1 then mf=0:sys 49209:return:rem music off
2020 mf=1:sys 49235:rem music on
2030 poke sid+24,fl:poke sid+23,rn
2040 return
5000 rem main screen
5010 poke 53280,0:poke 53281,0
5020 print"[147]"
5030 print" *** filter demo ***"
5040 print" file : ";n$
5050 print" f1 f3 f5 f7 [146]"
5060 print"sweep filterhelpmusic on/offexit[146]"
5110 print"[176]{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}[174]"
5120 print"{$7d}passfilters{$7d} filter parameters "
5130 print"[171]{$60}{$60}{$60}{$60}[178]{$60}{$60}{$60}{$60}[178]{$60}{$60}{$60}{$60}[179][176]{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}[174]"
5140 print"{$7d}high{$7d}low{$7d}band{$7d}{$7d}sweepctrl{$7d}"
5150 print"{$7d}{$7d}{$7d}{$7d}[171]{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}[179]"
5160 print"[171]{$60}{$60}{$60}{$60}{$7b}{$60}{$60}{$60}{$60}{$7b}{$60}{$60}{$60}{$60}[179]{$7d}limit-{$7d}"
5170 print"{$7d}1{$7d}[158]2{$7d}3{$7d}[171]{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}[179]"
5180 print"{$7d}{$7d}{$7d}{$7d}{$7d}rate{$7d}"
5190 print"[171]{$60}{$60}{$60}{$60}[177]{$60}{$60}{$60}{$60}[177]{$60}{$60}{$60}{$60}[179][173]{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}[189]"
5200 print"{$7d}resonance{$7d}"
5210 print"[173]{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}[189]"
5220 print" ";
5230 if hp=1 then print"[157][157][157][157] on [146]";
5240 print" ";:if lp=1 then print"[157][157][157][157] on [146]";
5250 print" ";:if bp=1 then print"[157][157][157][157] on [146]";
5260 print
5270 print" ";:if f1=1 then print"[157][157][157][157] on [146]";
5280 print" ";:if f2=1 then print"[157][157][157][157][158] on [146]";
5290 print" ";:if f3=1 then print"[157][157][157][157] on [146]";
5300 print
5310 print" [157][157][157][157]";str$(res)
5320 print"";tab(24);" [157][157][157][157]";str$(d1);" - [157][157][157][157]";str$(d2)
5330 print tab(24);" [157][157][157][157]";str$(sw)
5340 return
6000 rem help screen
6010 poke 53280,5:poke 53281,5:print"[147]";
6011 print" [f7] to continue [146][144]filtercontrols"
6012 print"{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}"
6013 print"[h][146][144]highpasson/off"
6014 print"[l][146][144]lowpasson/off"
6015 print"[b][146][144]bandpasson/off"
6016 print"[1][146][144]filterchannel1in/out"
6017 print"[2][146][144]filterchannel2in/out"
6018 print"[3][146][144]filterchannel3in/out"
6019 print"increase/decreaseresonance"
6020 print"[r][shift] & [r]"
6021 print"[144]increase/decreasevolume"
6022 print"[v][shift] & [v]"
6120 get k$:if k$<>chr$(136) then 6120
6130 gosub 5010:rem main screen
6140 return
30000 rem input new filename
30010 poke 53280,5:poke 53281,5
30020 print"[147] enter new filename : press [return] [146]";
30030 print
30040 print"file : ";n$
30050 print""
30060 l=14:tb=5:rs=1:gosub 32040:rem input subroutine
30070 if a>0 then n$=y$
30080 poke 53280,0:poke 53281,0
30085 print"[147]file : ";n$
30090 return
32000 rem input restriction subroutine
32010 rem l=length of input
32020 rem tb=tabulation of routine
32030 rem rs=character restrictions
32040 a=0:y$="":sp=1
32050 print tab(tb+l+1):print"[145][174][157][189][145]";:for x=0 to l+1:print"[157][157] ";:next:print"[145][176][157][173][145][164][157]";
32060 get x$:if x$="" then 32060
32070 if x$=chr$(160) or x$=" " or x$=chr$(20) or x$=chr$(13) then 32130
32080 if rs=0 then if x$=>"0" and x$=<"9" then 32130
32090 if rs=1 and x$=>chr$(35) and x$=<chr$(93) then 32130
32100 goto 32060
32110 if a=l-1 then print"[157][157]";
32120 goto 32060
32130 if x$=chr$(20) and a=0 then 32060
32140 if x$=chr$(13) and right$(y$,1)=" " then y$=left$(y$,len(y$)-1):a=a-1
32150 if x$=chr$(13) then print:return
32160 a=a+1:if x$<>chr$(32) then sp=0
32170 if a>l and x$<>chr$(20) then x$="":a=a-1
32180 if a<1 then x$="":a=0
32190 if x$=chr$(20) then print tab(a)"[157][164] [157][157]";:a=a-2:y$=left$(y$,len(y$)-1):goto 32110
32200 if x$=chr$(32) and sp=1 then x$="":a=a-1
32210 if x$=chr$(32) then sp=sp+1
32220 y$=y$+x$:print x$;:if a<l then print"[164][157]";
32230 goto 32060
39000 rem menu system routine
39010 a=0:print tab(t1);">"
39020 get x$:if x$="" then 39020
39030 if a=ll and x$=chr$(17) then a=a-1:print"[145][145]"
39040 if a=0 and x$=chr$(145) then a=a+1:print
39050 if x$=chr$(17) then a=a+1:print tab(t1);"[145] [157]>"
39060 if x$=chr$(145) then a=a-1:print tab(t1);"[145] [157][145]>"
39070 if x$=chr$(13) then return
39080 goto 39020
40000 rem load music file
40010 x$=".1":i=0
40020 n=0
40030 open 15,8,15
40040 open 2,8,2,n$+x$+",s,r"
40050 input#15,en,er$,tr,se
40060 if en<>0 then print"[147] load[146]";:goto 44010
40070 print" loading music file : [146]";
40080 input#2,a
40090 poke ch+i*256+n,a
40100 if a<>255 then n=n+1:goto 40080
40110 n(i+1)=n
40120 close 2
40130 close 15
40140 if i=0 then i=1:x$=".2":goto 40020
40150 if i=1 then i=2:x$=".3":goto 40020
40160 return
42000 rem load fsid registers
42010 open 15,8,15
42020 open 2,8,2,n$+".s,s,r"
42030 input#15,en,er$,tr,se
42040 if en<>0 then print"[147] load[146]";:goto 44010
42050 print" loading sound file : [146]";
42060 input#2,a
42070 poke 49275,a
42080 for ce=0 to 2
42090 for rg=0 to 6
42100 input#2,a
42110 poke fsid+rg+7*ce,a
42120 next rg,ce
42130 close 2
42140 close 15
42150 return
44000 rem file error routine
44010 close 2:close 15
44020 print" error : press [return] [146]";:print
44030 print"file : ";n$
44040 print"error # : ";en:print"";er$:print"tr = ";tr;" : se = ";se
44050 get k$:if k$<>chr$(13) then 44050
44060 return
50000 rem initialisation
50010 if peek(51712)=1 then 50120:rem machine code present
50020 rem load machine code
50030 poke 53280,5:poke 53281,5
50040 print"[147][176][174]"
50050 print"filter demo"
50060 print"v.h.berryc.1989"
50070 print"[173][189]"
50080 print"loadingmachinecode"
50090 fg=fg+1:if fg=1 then load"sequencer mc",8,1
50100 if fg=2 then load "note table mc",8,1
50110 rem define system variables
50120 n$="demo file":rem default filename
50130 fsid=49175:rem false sid address
50140 ch=51968:rem channel data address
50150 sid=54272:rem sound chip address
50152 bk$=" "
50160 rem define filter parameters
50170 volume=8:res=12
50180 rem filters settings
50190 f1=0:rem channel 1 filter off
50200 f2=1:rem channel 2 filter on
50210 f3=1:rem channel 3 filter on
50220 hp=0:rem high pass off
50230 lp=0:rem low pass off
50240 bp=1:rem band pass on
50250 rem sweep settings
50260 d1=10:d2=180:rem depth of sweep high and low
50270 sw=10:rem speed of sweep
50280 fl=volume+lp*16+bp*32+hp*64
50290 rn=res*16+f3*4+f2*2+f1
50300 return